package edu.eypt.radioalertdialogsample;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class RadioAlertDialogSampleActivity extends Activity {
	private Button button;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		intializeUI();
	}

	private void intializeUI() {
		button = (Button) findViewById(R.id.button1);
		button.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				AlertDialog.Builder builder = new AlertDialog.Builder(
						RadioAlertDialogSampleActivity.this);
				builder.setTitle("Choose one item");
				final CharSequence[] items = { "1", "2", "3", "4" };
				builder.setSingleChoiceItems(items, -1,
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int item) {
								Toast.makeText(getApplicationContext(),
										items[item], Toast.LENGTH_SHORT).show();
								dialog.dismiss();
							}
						});
				builder.show();

			}
		});
	}
}